<p>This test verifies that an exception thrown during array sort immediately ends execution.</p>
<p>If the test passes, you'll see a pass message below.</p>

<pre id="console">FAIL: Exception did not propagate from array sort.</pre>

<script>
function log(s)
{
    document.getElementById("console").innerHTML = s + "\n";
}

if (window.testRunner)
    testRunner.dumpAsText();

var passed = true;

var array = [ 1, 2, 3 ];
var sortFunction = (function () {
    var alreadyCalled = false;
    return function (a, b)
    {
        if (alreadyCalled)
            passed = false;

        alreadyCalled = true;
        throw 'threw';
    };
})();

try {
    array.sort(sortFunction);
} catch(e) {
    var result = passed ? "PASS"
                        : "FAIL: sort function was called after an exception was thrown"
    log (result);
}
</script>
